import { createSlice } from '@reduxjs/toolkit'
import type { PayloadAction } from '@reduxjs/toolkit'

export interface CounterState {
    city: string
}

const initialState: CounterState = {
    city: '北京',
}

export const counterSlice = createSlice({
    name: 'counter',
    initialState,
    reducers: {
        changeCity: (state, action: PayloadAction<string>) => {
            state.city = action.payload
        },
    },
})

// Action creators are generated for each case reducer function
export const { changeCity } = counterSlice.actions

export default counterSlice.reducer